{include file="public/head"/}
<div id="main-page">
    <div class="wap">
        <div class="loader">
            <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"></circle>
            </svg>
        </div>
        <div class="container tac py-3">
            <h2 class="fc-yellow">{$data['replace']['congratulations']}</h2>
            <h1 class="fc-red">{$data['replace']['participate']}</h1>
            <h2 class="fc-light">{$data['replace']['works']}</h2>
        </div>
        <div class="container">
            <video src="{$data['video']['path']}" {if $data['video']['pic']}poster="{$data['video']['pic']}"{/if} controls loop preload></video>
        </div>
        <div class="px-3">
            <div class="bg-base p-3 br-30 mt-2">
                <h2 class="tac mb-3">{$data['replace']['introduction']}</h2>
                <div class="content">{:htmlspecialchars_decode($data['content'])}</div>
            </div>
        </div>
        <div style="height:1.7rem;"></div>
        <div class="btnbox">
            <div class="row">
                {if $data['paytype']==0}
                <div class="col-6">
                    <a class="btn btn-block" href="{$_W['baseurl']}/web/card?sale_id={$data['id']}">{$data['replace']['view_button']}</a>
                </div>
                <div class="col-6">
                    <button class="btn btn-block btn-red" id="get_button">{$data['replace']['get_button']}</button>
                </div>
                {else}
                <div class="col-12">
                    <button class="btn btn-block btn-red" id="get_button">{$data['replace']['get_button']}</button>
                </div>
                {/if}
                <div class="col-12">
                    <div class="tac mt-2" style="font-size:0.2rem;">
                        <p style="color:#aaa;">点击按钮后账号会默认发出视频，点击按钮默认为已知并同意规则。</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            var is_submit = true;
            var msg = '{$msg}';
            if (msg) {
                dialog(msg);
                return false;
            }
            $('#get_button').on('click', function () {
                if (msg) {
                    dialog(msg);
                    return false;
                }
                if (is_submit) {
                    is_submit = false;
                    $('.loader').show();
                    $.get("{$_W['baseurl']}/web/card/create?sale_id={$data['id']}&idx={$videoidx}", function (res) {
                        if (res && res.code == 0) {
                            dialog(res.msg);
                            $.get("{$_W['baseurl']}/web/video/verify?sale_id={$data['id']}&mid={$_W['fans']['id']}");
                            $('.van-dialog__footer').on('click', function () {
                                $('.van-overlay').fadeOut(50);
                                $('.van-dialog').fadeOut(100);
                                window.location.href = res.data;
                            });
                        } else {
                            dialog(res.msg ? res.msg : '提交失败！');
                        }
                        is_submit = true;
                        $('.loader').hide();
                    });
                }
            });
        });
    </script>
</div>
{include file="public/footer"/}